const config = require('@/utils/config.js').default

exports.formatSex = value => {
  if (value || value === 0) {
    const obj = {
      0: '不限',
      1: '男',
      2: '女'
    }
    return obj[value] || value
  }
}

exports.foamatVetifyState = value => {
  if (value || value === 0) {
    const obj = {
      1: '已认证',
      0: '未认证'
    }
    return obj[value] || value
  }
}

exports.formatDepa = value => {
  if (value) {
    const _value = String(value)
    const obj = {
      1: '电力工程系',
      2: '动力工程系',
      3: '经济管理系',
      4: '电气工程系',
      5: '信息通信系'
    }
    const Depas = _value.split(',')
    const DepasTrans = []
    if (Depas.length > 1) {
      Depas.map(item => {
        DepasTrans.push(obj[item] || item)
      })
      return DepasTrans.join('、')
    }
    return obj[value] || value
  }
}

exports.formateClassify = value => {
  if (value) {
    for (let i = 0; i < config.activityClassOptions.length; i++) {
      if (config.activityClassOptions[i].value === value.toString()) {
        return config.activityClassOptions[i].label
      }
    }
  }
  return value
}

exports.formateActivityState = value => {
  if (value) {
    for (let i = 0; i < config.activityStatusOptions.length; i++) {
      if (config.activityStatusOptions[i].value === value) {
        return config.activityStatusOptions[i].label
      }
    }
  }
  return value
}

exports.formatUserGroup = value => {
  if (value) {
    const obj = {
      1: '学生',
      2: '管理员',
      3: '超级管理员',
      4: '教师'
    }
    return obj[value] || value
  }
}

exports.statusTagType = value => {
  if (value) {
    let res = null
    const state = value.ac_state
    if (state === 2) {
      res = 'warning'
    } else if (state === 3) {
      res = 'success'
    } else if (state === 4) {
      res = 'danger'
    } else if (state === 5) {
      res = 'info'
    } else if (state === 5010) {
      res = null
    } else if (state === 6) {
      res = 'warning'
    } else if (state === 7) {
      res = 'info'
    } else if (state === 8) {
      res = 'info'
    }
    return res
  }
}

